package org.bbb.library1.views;

/*******************************************************************************
 * Copyright (c) 2007 Finalist IT Group B.V.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *    Rob Schellhorn - initial API and implementation
 *******************************************************************************/


import org.bbb.library1.ImageConstants;
import org.bbb.library1.RcpDemoPlugin;
import org.bbb.library1.model.Book;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Image;


/**
 * @author Rob Schellhorn
 */
public class ExplorerLabelProvider extends LabelProvider {

   /*
    * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object)
    */
   @Override
   public Image getImage(Object element) {
      if (element instanceof Book) {
         return RcpDemoPlugin.getDefault().getImageRegistry().get(ImageConstants.BOOK_ICON);
      }
      return super.getImage(element);
   }

   /*
    * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
    */
   @Override
   public String getText(Object element) {
      if (element instanceof Book) {
         return Book.class.cast(element).getTitle();
      }
      return super.getText(element);
   }
}